package com.cxy.juc;

public class SynchronizedThree {
    public static void main(String[] args) {
        TestThree test1 = new TestThree();
        TestThree test2 = new TestThree();
        Thread t1 = new Thread(test1,"thread-1");
        Thread t2 = new Thread(test2,"thread-2");
        t1.start();
        t2.start();
    }
}

class TestThree implements Runnable {

    @Override
    public void run() {
        method();
    }

    public void method(){
        synchronized (TestThree.class){
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName() + "-->" + i);
            }
        }
    }
}
